﻿Public Class frmMain
#Region "<< -Attributes- >>"
    Private _Logout As Boolean = False
#End Region

#Region "<< -Events- >>"
    Private Sub frmMain_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim wTmp As String = IIf(Date.Now.Hour >= 12 And Date.Now.Hour < 24, "pm", "pm")
        lblHour.Text = String.Format("{0} {1}", Date.Now.ToShortTimeString(), wTmp)

        Timer.Interval = 60000 '1 min
        Timer.Start()
    End Sub

    Private Sub Timer_Tick(sender As System.Object, e As System.EventArgs) Handles Timer.Tick
        Dim wTmp As String = IIf(Date.Now.Hour >= 12 And Date.Now.Hour < 24, "pm", "am")
        lblHour.Text = String.Format("{0} {1}", Date.Now.ToShortTimeString(), wTmp)
    End Sub

    Private Sub barBtnAppExit_Click(sender As System.Object, e As System.EventArgs) Handles barBtnAppExit.Click
        UC_AppointmentPreviewPanel1.StopTimer()
        Timer.Stop()
        Application.Exit()
    End Sub

    Private Sub frmMain_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        If Not _Logout Then Application.Exit()
    End Sub

    Private Sub barBtnLogout_Click(sender As System.Object, e As System.EventArgs) Handles barBtnLogout.Click
        Dim wFrmLogin As frmLogin = New frmLogin
        wFrmLogin.Show()
        UC_AppointmentPreviewPanel1.StopTimer()
        Timer.Stop()
        _Logout = True
        Me.Close()
    End Sub

    Private Sub barBtnProfiles_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnProfiles.ItemClick
        Dim wFrmABMProfiles As frmABMProfiles = New frmABMProfiles
        wFrmABMProfiles.Screen = Common.CommonDefinitions.Screen.ABMProfiles
        wFrmABMProfiles.ShowDialog()
    End Sub

    Private Sub barBtnUses_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnUses.ItemClick
        Dim wFrmABMUsers As frmABMUsers = New frmABMUsers
        wFrmABMUsers.Screen = Common.CommonDefinitions.Screen.ABMUsers
        wFrmABMUsers.ShowDialog()
    End Sub

    Private Sub barBtnOwners_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnOwners.ItemClick
        Dim wUC_ABMOwners As UC_ABMOwner = New UC_ABMOwner
        pnlBody.Controls.Clear()
        pnlBody.Controls.Add(wUC_ABMOwners)
        wUC_ABMOwners.Dock = DockStyle.Fill
    End Sub

    Private Sub barBtnProperties_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnProperties.ItemClick
        Dim wUC_ABMProperies As UC_ABMProperties = New UC_ABMProperties
        pnlBody.Controls.Clear()
        pnlBody.Controls.Add(wUC_ABMProperies)
        wUC_ABMProperies.Dock = DockStyle.Fill
    End Sub

    Private Sub barBtnClients_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnClients.ItemClick
        Dim wUC_ABMClients As UC_ABMClients = New UC_ABMClients
        pnlBody.Controls.Clear()
        pnlBody.Controls.Add(wUC_ABMClients)
        wUC_ABMClients.Dock = DockStyle.Fill
    End Sub

    Private Sub barBtnAgenda_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnAgenda.ItemClick
        Dim wUc_agenda As UC_Agenda = Nothing

        Try
            If pnlBody.Controls.Count > 0 Then
                If TypeOf pnlBody.Controls(0) Is UC_Agenda Then
                    Return
                Else
                    pnlBody.Controls.Clear()
                End If
            End If
            wUc_agenda = New UC_Agenda
            pnlBody.Controls.Add(wUc_agenda)
            wUc_agenda.Dock = DockStyle.Fill
        Catch ex As Exception
            _MsgBox.ShowMessage("Excepción", ex.Message, frmMessage.MessageType.Error_, frmMessage.MessageButtons.Ok)
        End Try
    End Sub

    Private Sub barBtnComision_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnComision.ItemClick
        Dim wUC_ABMCommssion As UC_ABMCommission = New UC_ABMCommission
        pnlBody.Controls.Clear()
        pnlBody.Controls.Add(wUC_ABMCommssion)
        wUC_ABMCommssion.Dock = DockStyle.Fill
    End Sub

#End Region

End Class
